﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Bouyei.Geo.GeoParsers.Vct
{
    public class VctReader : BaseFile
    {
        public VctReader(string vctFile)
            : base(vctFile) { }

        public VctReader(string vctFile,Encoding encoding)
          : base(vctFile,encoding) { }

        public VctInfo Reader()
        {
            var reader = StrReaderStream();

            var header = new VctHeader();
            bool isTrue = header.FromReader(reader);
            if (isTrue == false) return null;

            VctInfo vct = new VctInfo()
            {
                vctHeader = header,
                vctFeatureCode = new VctFeatureCode(header),
                vctTableStructure = new VctTableStructure(header),
            };

            isTrue = vct.vctFeatureCode.FromReader(reader);
            if (isTrue == false)
                throw new Exception("解析FeatureCode失败");

            isTrue = vct.vctTableStructure.FromReader(reader);
            if (isTrue == false)
                throw new Exception("解析TableStructure失败");

            return vct;
        }

        public override void Dispose()
        {
            base.Dispose();
        }
    }
}
